PhP/HTML play button [migrated]
Posted
by
Marian
on Pro Webmasters
See other posts from Pro Webmasters
or by Marian
Published on 2012-03-21T18:09:13Z
Indexed on
2012/03/21
23:40 UTC
Read the original article
Hit count: 602
I'm wanting to make my own small webpage, I've got a domain Saoo.eu As you see there is a small play button in the corner witch plays a playlist. Is there anyway to have that playbutton on each page I'd add in the future without resetting every time the page changes? Am I forced to use iFrames for that?
This is my player code
<button id="audioControl" style="width:30px;height:25px;"></button>
<audio id="aud" src="" autoplay autobuffer />
Script:
$(document).ready(function() {
$('#audioControl').html('II');
if(Modernizr.audio && Modernizr.audio.mp3) {
audio.setAttribute("src",'http://daokun.webs.com/play0.mp3');
} else if(Modernizr.audio && Modernizr.audio.wav) {
audio.setAttribute("src", 'http://daokun.webs.com/play0.ogg');
}
});
var audio = document.getElementById('aud'),
count = 0;
$('#audioControl').toggle(
function () {
audio.pause();
$('#audioControl').html('>');
},
function () {
audio.play();
$('#audioControl').html('II');
}
);
audio.addEventListener("ended", function() {
count++;
if(count == 4){count = 0;}
if(Modernizr.audio && Modernizr.audio.mp3) {
audio.setAttribute("src",'http://daokun.webs.com/play'+count+'.mp3');
} else if(Modernizr.audio && Modernizr.audio.wav) {
audio.setAttribute("src", 'http://daokun.webs.com/play'+count+'.ogg');
}
audio.load();
});
© Pro Webmasters or respective owner